home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #1
/
Amiga Plus 1995 #1.iso
/
fish-disketten
/
fish_941-950
/
d949
/
bbbbs
/
bbbbs65.lha
/
rexx
/
BuildALPHA.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-10-04
|
10KB
|
385 lines
/* $VER: BuildALPHA.rexx 6.4 (4.10.93)
copyright 1990-93 Richard Lee Stockton
FREELY DISTRIBUTABLE
Build the main filelist "Lists/Files" from the filenotes,
then build "Lists/Files.ALPHA" from that list and the filenotes.
KeyWords field (if empty) is built from the long description (if any).
Bytes field is corrected (if necessary) to match real filesize.
If COLLECT is passed as an argument, will collect files that have
no file description and construct descriptions for them using the
filecomment of the file (if any) for note data. Note that the
filecomment is then blanked so it won't interfere with displays.
IF NOFILEBUILD is passed the argument, only the ALPHA list is rebulit.
*/
ARG collectflag .
IF collectflag='?' THEN
DO
DO i=1 TO 14
SAY SOURCELINE(i)
END
EXIT
END
/* If the QuickSortPort not found then try to run setup.rexx */
IF ~show('P','QuickSortPort') THEN CALL setup.rexx()
IF ~show('P','QuickSortPort') THEN CALL GETOUT(666)
figarg='s:CONFIG.BBS'
IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
x=OPEN(f,figarg,'R')
IF x=0 THEN
DO
SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
EXIT(20)
END
lynes.=''
DO i=1 TO 8
lynes.i=READLN(f)
END
CALL CLOSE(f)
compos=POS('/*',lynes.1)
IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
bbsname = STRIP(lynes.1)
sysop = WORD(lynes.2,1)
bbspath = WORD(lynes.6,1)
IF ~EXISTS(bbspath) THEN
DO
SAY 'The bbspath, 'bbspath', does not exist!'
EXIT(21)
END
testchar=RIGHT(bbspath,1)
IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
libpath = WORD(lynes.8,1)
IF ~EXISTS(libpath) THEN
DO
SAY 'The library path, 'libpath', does not exist!'
EXIT(22)
END
testchar=RIGHT(libpath,1)
IF testchar~='/' & testchar~=':' THEN libpath=libpath'/'
IF SHOW('P','BBBBS') THEN CALL PRAGMA('P',-2)
etime=TIME('R')
IF collectflag='COLLECT' THEN
DO
OPTIONS PROMPT 'Shall I clear each filecomment after using in the description? (Yn) > '
PULL clearflag .
clearflag=LEFT(STRIP(clearflag),1)
SAY 'Searching for files with no file descriptions...'
filelibs=SHOWDIR(libpath,'D')
DO i=1 TO WORDS(filelibs)
thislib=WORD(filelibs,i)
realfiles=SHOWDIR(libpath||thislib)
DO j=1 TO WORDS(realfiles)
thisfile=WORD(realfiles,j)
IF ~EXISTS(bbspath'FileNotes/'thislib'/'thisfile) THEN CALL makenote
END
END
IF ~DATATYPE(lastfile,'N') THEN
DO
SAY 'All files in the libraries have descriptions.'
EXIT
END
END
IF collectflag~='NOFILEBUILD' | ~EXISTS(bbspath'Lists/Files') THEN
DO
libs=SHOWDIR(bbspath'FileNotes','D')
lynes.=''
latest=0
SAY 'Building Files list.'
DO i=1 TO WORDS(libs)
lib=WORD(libs,i)
notes=SHOWDIR(bbspath'FileNotes/'lib,'F')
DO j=1 TO WORDS(notes)
note=WORD(notes,j)
file=libpath||lib'/'note
IF ~EXISTS(file) THEN
DO
temp=WORD(STATEF(bbspath'FileNotes/'lib'/'note),8)
IF temp~='' THEN file=temp
IF ~EXISTS(file) THEN SAY file 'does not exist.'
END
IF OPEN(f,bbspath'FileNotes/'lib'/'note,'R')=0 THEN
DO
IF EXISTS(file) THEN
SAY 'Could not open file description for' lib'/'note
ELSE SAY libpath||lib'/'note 'does not exist.'
ITERATE j
END
line=READLN(f)
filenum=WORD(line,2)
IF ~DATATYPE(filenum,'N') THEN
DO
SAY '*** Bad file description!' lib'/'note
SAY line
ITERATE j
END
filenum=filenum%1
line=READLN(f)
filename=STRIP(WORD(line,2))
CALL CLOSE(f)
IF UPPER(filename)~=UPPER(note) THEN
DO
SAY 'Name: field does not match actual filename!'
SAY 'Changing Name: 'filename' in file description to 'note
x=OPEN(f,bbspath'FileNotes/'lib'/'note,'R')
IF x=0 THEN EXIT 20
text.=''
DO i=1
x=READLN(F)
IF EOF(f) THEN LEAVE i
text.i=x
END
CALL CLOSE(f)
text.0=i-1
text.2=OVERLAY(note,text.2,7,27)
CALL DELAY(50)
x=OPEN(f,bbspath'FileNotes/'lib'/'note,'W')
IF x=0 THEN EXIT 20
DO i=1 TO text.0
CALL WRITELN(f,text.i)
END
CALL CLOSE(f)
filename=note
END
IF lynes.filenum~='' THEN
SAY 'Duplicate file numbers! 'filenum lynes.filenum '&' lib filename
lynes.filenum=lib filename
IF filenum>latest THEN latest=filenum
END
END
CALL SETCLIP('BBS_maint','File-Building')
SAY 'Writing Files list.'
x=OPEN(f,bbspath'Lists/Files','W')
IF x=0 THEN
DO
SAY '*** Failure! Error opening' bbspath'Lists/Files'
CALL GETOUT(23)
END
DO i=1 TO latest
IF lynes.i='' THEN ITERATE i
CALL WRITELN(f,i lynes.i)
END
CALL CLOSE(f)
CALL SETCLIP('BBS_maint')
END
SAY 'Reading Libraries list.'
x=OPEN(f,bbspath'Lists/Libraries','R')
IF x=0 THEN CALL GETOUT(24);
libs.=''
DO i=1
line=READLN(f)
IF EOF(f) THEN LEAVE i
indx=WORD(line,1)
IF ~DATATYPE(indx,'N') THEN ITERATE i
libname=UPPER(WORD(line,2))
libs.libname=indx
END
CALL CLOSE(f)
SAY 'Reading Files list.'
x=OPEN(f,bbspath'Lists/Files','R')
IF x=0 THEN CALL GETOUT(25);
lynes.=''
DO i=1
line=READLN(f)
IF EOF(f) THEN LEAVE i
lynes.i=line
END
CALL CLOSE(f)
lynes.0=i-1
SAY 'Building Files.ALPHA list.'
DO i=1 TO lynes.0
num=WORD(lynes.i,1)
lib=WORD(lynes.i,2)
libname=UPPER(lib)
file=WORD(lynes.i,3)
fullfile=libpath||lib'/'file
IF ~EXISTS(fullfile) THEN
DO
temp=WORD(STATEF(bbspath'FileNotes/'lib'/'file),8)
IF temp~='' THEN fullfile=temp
IF ~EXISTS(fullfile) THEN SAY fullfile 'does not exist.'
END
IF OPEN(f,bbspath'FileNotes/'lib'/'file,'R')=0 THEN
DO
IF EXISTS(fullfile) THEN
SAY 'Could not find filenote for' lib'/'file '!'
ELSE SAY fullfile 'has neither file nor note!'
ITERATE i
END
line=READLN(f)
PARSE VAR line . 'KeyWords:' keywords
notebytes=WORD(READLN(f),4)
IF LENGTH(keywords)<3 THEN
DO
CALL READLN(f)
CALL READLN(f)
line=READLN(f)
CALL CLOSE(f)
IF line~='' THEN
DO
keywords=STRIP(LEFT(line,32))
CALL fixkeywords()
END
END
ELSE CALL CLOSE(f)
bytes=0
IF EXISTS(fullfile) THEN
DO
bytes=WORD(STATEF(fullfile),2)
IF bytes~=notebytes THEN CALL fixbytes()
END
ELSE bytes=notebytes
lynes.i=LEFT(file,22-LENGTH(bytes)) bytes RIGHT(num,5) RIGHT(libs.libname,2)
lynes.i=lynes.i LEFT(lib,12) TRIM(LEFT(STRIP(keywords),32))
END
SAY 'Sorting Files.ALPHA list.'
CALL QSORT(1,lynes.0,lynes)
SAY 'Saving Files.ALPHA list.'
CALL SETCLIP('BBS_maint','File-Building')
x=OPEN(f,bbspath'Lists/Files.ALPHA','W')
IF x=0 THEN CALL GETOUT(25)
DO i=1 TO lynes.0
CALL WRITELN(f,lynes.i)
END
CALL CLOSE(f)
CALL SETCLIP('BBS_maint')
CALL GETOUT(0)
EXIT
GETOUT:
ARG outnum .
CALL SETCLIP('BBS_maint')
IF outnum>0 THEN SAY 'Error number' outnum'. Refer to BuildALPHA.rexx'
mins=TIME('E')%60
secs=TRUNC(TIME('E')//60)
IF secs<10 THEN secs='0'secs
SAY 'Elapsed time file building =' mins':'secs
EXIT(outnum);
fixkeywords:
SAY 'Fixing keywords field for' lib'/'file
fixfile=bbspath'FileNotes/'lib'/'file
finfo=STATEF(fixfile)
comment=''
IF WORDS(finfo)>7 THEN comment=STRIP(SUBSTR(finfo,WORDINDEX(finfo,8)))
fxlines.=''
x=OPEN(f,fixfile,'R')
IF x=0 THEN
DO
SAY 'Failed to open' fixfile 'for reading! (keywords adjustment)'
RETURN
END
DO fx=1
line=READLN(f)
IF EOF(f) THEN LEAVE fx
fxlines.fx=line
END
CALL CLOSE(f)
fxlines.0=fx-1
fxlines.1=OVERLAY('KeyWords:' keywords,fxlines.1,WORDINDEX(fxlines.1,3),LENGTH(keywords)+10)
x=OPEN(f,fixfile,'W')
IF x=0 THEN
DO
SAY 'Failed to open' fixfile 'for writing! (keywords adjustment)'
RETURN
END
DO fx=1 TO fxlines.0
CALL WRITELN(f,fxlines.fx)
END
CALL CLOSE(f)
IF comment~='' THEN ADDRESS COMMAND 'filenote' fixfile comment
RETURN
fixbytes:
SAY 'Fixing bytes field for' lib'/'file
fixfile=bbspath'FileNotes/'lib'/'file
finfo=STATEF(fixfile)
comment=''
IF WORDS(finfo)>7 THEN comment=STRIP(SUBSTR(finfo,WORDINDEX(finfo,8)))
fxlines.=''
x=OPEN(f,fixfile,'R')
IF x=0 THEN
DO
SAY 'Failed to open' fixfile 'for reading! (byte adjustment)'
RETURN
END
DO fx=1
line=READLN(f)
IF EOF(f) THEN LEAVE fx
fxlines.fx=line
END
CALL CLOSE(f)
fxlines.0=fx-1
fxlines.2=OVERLAY(bytes,fxlines.2,WORDINDEX(fxlines.2,4),LENGTH(bytes)+1)
x=OPEN(f,fixfile,'W')
IF x=0 THEN
DO
SAY 'Failed to open' fixfile 'for writing! (byte adjustment)'
RETURN
END
DO fx=1 TO fxlines.0
CALL WRITELN(f,fxlines.fx)
END
CALL CLOSE(f)
IF comment~='' THEN ADDRESS COMMAND 'filenote' fixfile comment
RETURN
makenote:
CALL MAKEDIR(bbspath'FileNotes/'thislib)
x=OPEN(f,bbspath'FileNotes/'thislib'/'thisfile,'W')
IF x=0 THEN
DO
SAY bbspath'FileNotes/'thislib'/'thisfile 'failed to open!'
RETURN
END
x=OPEN(ff,bbspath'Numbers/LastFile','R')
IF x~=0 THEN lastfile=READLN(ff)+1
ELSE lastfile=1
CALL CLOSE(ff)
ADDRESS COMMAND 'ECHO >'bbspath'Numbers/LastFile 'lastfile
finfo=STATEF(libpath||thislib'/'thisfile)
bytes=WORD(finfo,2)
comment=''
IF WORDS(finfo)>7 THEN comment=STRIP(SUBSTR(finfo,WORDINDEX(finfo,8)))
CALL WRITELN(f,'File: 'LEFT(lastfile,5)' KeyWords:' STRIP(LEFT(comment,31)))
CALL WRITELN(f,'Name: 'LEFT(thisfile,27)' Size: 'bytes' bytes Downloads: 0')
CALL WRITELN(f,'From: 'LEFT(sysop,27)' Date: 'DATE() TIME('C')' Lib: 'thislib)
CALL WRITELN(f,LEFT('',74,'='))
IF LENGTH(comment)>31 THEN CALL WRITELN(f,comment)
CALL CLOSE(f)
IF comment~='' & clearflag~='N' THEN
ADDRESS COMMAND 'filenote' libpath||thislib'/'thisfile '22'x||'22'x
SAY 'Added' thisfile 'to the' thislib 'library.'
RETURN
/* Build ALPHA.rexx */